<template>
  <div class="partBox">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>活动管理</el-breadcrumb-item>
      <el-breadcrumb-item>活动列表</el-breadcrumb-item>
      <el-breadcrumb-item>活动详情</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="main">
      <div class="main-left">
        <LoupeViews :img="img"></LoupeViews>
      </div>
      <div class="main-right">
        <MainRight :list="list"></MainRight>
      </div>
    </div>
    <div class="suggest">
      <div class="suggest-header">
        <i class="icon"></i>
        <span>同类商品推荐</span>
      </div>
      <div class="footer">
        <el-carousel :interval="5000" arrow="always">
          <el-carousel-item  class="sList"  v-for="item in 4" :key="item">
            <div class="sList-item" v-for="items in sList.slice((item-1)*4,item*4)" :key="items">
                <img :src="items.picture">
                <p class="name">{{items.name}}</p>
                <p class="price">{{items.price}}</p>
            </div>
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>
  </div>
</template>

<script>
import { partList,relevant } from "@/api/part";
import LoupeViews from "./components/LoupeViews.vue";
import MainRight from "./components/MainRight.vue";
export default {
  name: "PartiCulars",
  components: { LoupeViews, MainRight },
  data() {
    return {
      list: [],
      img: [
        {
          src: "",
          bigsrc: "",
        },
        {
          src: "",
          bigsrc: "",
        },
        {
          src: "",
          bigsrc: "",
        },
        {
          src: "",
          bigsrc: "",
        },
        {
          src: "",
          bigsrc: "",
        },
      ],
      sList:[],
      id:''
    };
  },
  mounted() {
    this.id = this.$route.query.id;
    partList(this.id).then((res) => {
      this.list = res.data.result;

      for (let i = 0; i < res.data.result.mainPictures.length; i++) {
        this.img[i].src = res.data.result.mainPictures[i];
        this.img[i].bigsrc = res.data.result.mainPictures[i];
        
      }
      console.log(this.list);
     
    });
    relevant().then((res) => {
      this.sList = res.data.result;
      console.log(this.sList)
    })
  },
};
</script>

<style lang="scss" scoped>
.partBox {
  width: 1240px;
  margin: 0 auto;
  .main {
    width: 100%;
    margin-top: 15px;
    background: #fff;
    padding: 15px 25px;
    display: flex;
  }
}
.suggest{
  width: 100%;
  margin-top: 20px;
  background: #fff;
  padding: 0 25px;
  .suggest-header{
    height: 80px;
    line-height: 80px;
    padding: 0 20px;
      i{
        display: inline-block;
        width: 16px;
        height: 16px;
        border-top: 4px solid #27ba9b;
        border-right: 4px solid #27ba9b;
        box-sizing: border-box;
        position: relative;
        transform: rotate(45deg);
      }
      i::before{
        content: "";
        width: 10px;
        height: 10px;
        position: absolute;
        left: 0;
        top: 2px;
        background: #bcf1e6;
    }
    span{
      font-size: 20px;
      padding-left: 10px;
    }
  }
}
.el-carousel__item h3 {
    color: #475669;
    font-size: 18px;
    opacity: 0.75;
    line-height: 300px;
    margin: 0;
}
.footer{
  height: 300px;
  .sList{
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-around;
    .sList-item{
      width: 240px;
      text-align: center;
      img{
        padding: 20px;
        width: 150px!important;
        height: 150px!important;
      }
      .name{
        font-size: 16px;
        color: #666;
        padding: 0 40px;
      }
      .price{
        font-size: 16px;
        color: #cf4444;
        margin-top: 15px;
      }
    }
  }
}
</style>